package com.comleader.uap.controller;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.comleader.common.core.web.page.PageResult;
import com.comleader.uap.common.page.PageQuery;
import com.comleader.uap.common.response.Result;
import com.comleader.uap.pojo.query.UrlVisitQuery;
import com.comleader.uap.pojo.vo.UrlVisitDetailVO;
import com.comleader.uap.pojo.vo.UrlVisitVO;
import com.comleader.uap.service.UrlVisitService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @Description 非法网站访问
 * @Auhtor 王坤
 * @Date 2024/11/26 18:01
 */
@Api(tags = "非法网站访问")
@Validated
@RestController
@RequestMapping("/url-visit")
public class UrlVisitController {

    @Resource
    private UrlVisitService UrlVisitService;

    /**
     * @Description 分页查询
     * @Auhtor 王坤
     * @Date 2024/11/26 18:01
     * @param query
     * @return
     */
    @ApiOperation(value = "分页查询")
    @PostMapping("/list")
    public Result<PageResult<UrlVisitVO>> list(@Valid @RequestBody PageQuery<UrlVisitQuery> query) {
        return Result.success(UrlVisitService.selectList(query));
    }

    /**
     * @Description 导出
     * @Auhtor 王坤
     * @Date 2024/11/28 18:33
     * @param query
     * @param response
     */
    @ApiOperation(value = "导出")
    @PostMapping("/export")
    public void export(@RequestBody UrlVisitQuery query, HttpServletResponse response) throws IOException {
        UrlVisitService.export(query, response);
    }

    /**
     * @Description 详情-分页查询
     * @Auhtor 王坤
     * @Date 2024/11/26 18:01
     * @param query
     * @return
     */
    @ApiOperation(value = "详情-分页查询")
    @PostMapping("/detailList")
    public Result<PageResult<UrlVisitDetailVO>> detailList(@Valid @RequestBody PageQuery<UrlVisitQuery> query) {
        return Result.success(UrlVisitService.selectDetailList(query));
    }

    /**
     * @Description 详情-特征查询
     * @Auhtor 王坤
     * @Date 2024/11/26 18:01
     * @param query
     * @return
     */
    @ApiOperation(value = "详情-特征查询")
    @PostMapping("/detailFeature")
    public Result<List<Integer>> detailFeature(@Valid @RequestBody UrlVisitQuery query) {
        return Result.success(UrlVisitService.detailFeature(query));
    }

}
